-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PIR+CINN]Fix cinn_op.GroupOp insert bug for WriteAfterRead #62529
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
你的PR提交成功,感谢你对开源项目的贡献! |
tc20042008
approved these changes
Mar 10, 2024
winter-wang
approved these changes
Mar 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for rectify in pir/include/operaton.h.
hitywt
pushed a commit
to hitywt/Paddle
that referenced
this pull request
Mar 11, 2024
…ddle#62529) * [PIR+CINN]Fix cinn_op.GroupOp insert bug for WriteAfterRead * fix bug * refine code * fix cond typo * fix std::distance * add strong verify after build_cinn_pass * fix typo
hitywt
pushed a commit
to hitywt/Paddle
that referenced
this pull request
Mar 11, 2024
…ddle#62529) * [PIR+CINN]Fix cinn_op.GroupOp insert bug for WriteAfterRead * fix bug * refine code * fix cond typo * fix std::distance * add strong verify after build_cinn_pass * fix typo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
Bug fixes
PR changes
Others
Description
Pcard-67164
一、问题描述
在CINN后端中,需要对「支持」融合的算子进行图遍历,识别并圈定为GroupOp。遍历过程是基于「图语义」的,意味着待融合的算子在「Program」层面可能相距比较远,而且它们之间夹杂着各自依赖的上游Op。因此如何选取融合后算子的「插入点」是一个非常重要的位置,若插入不恰当,极其容易引入类似编程语言中「使用未定义变量」的错误。
举个例子,如下图的「融合Group」列图中的算子E位置就是错的。
二、解决思路
由于融合Group仅发生在Block级别,因此我们只需关心Block内部的算子之间顺序是否「合法」即可,此PR中的思路包含如下定义:
整个思路包含三个关键步骤:
为什么不处理『D之前』的上游算子列表?
答:从Program的Op-by-Op语义上,对于固定的算子Group,只需要保证所有『读入』的算子在前面,『写出』的算子在后面即可,故我们选择『第一个下游算子D』作为候选插入点,则『D之前』的算子顺序都是正确的,无需处理。
只调整Group算子直接依赖的上游算子是不是就可以了?
答:不可以,要递归解析上游依赖&依赖....所有算子,但限制在: